﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Web;

namespace NuaTarDoneng.Tail
{
    public static class PubWays
    {
        public static string EncryptToMD5(string str)
        {
            MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
            byte[] stream = System.Text.Encoding.UTF8.GetBytes(str);
            byte[] hash = md5.ComputeHash(stream);
            return ByteArrayToHexString(hash);
        }
        private static string ByteArrayToHexString(byte[] values)
        {
            StringBuilder sb = new StringBuilder();
            foreach (byte value in values)
            {
                sb.AppendFormat("{0:X2}", value);
            }
            return sb.ToString();
        }
        
    }
}